<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>点餐系统</title>
<meta name="Keywords" content="点餐系统">
<meta name="Description" content="点餐系统">
<link href="__CSS_ADMIN_PATH__/css.css" rel="stylesheet" type="text/css">
<link href="__PUBLIC_PATH__/fancybox/source/jquery.fancybox.css" rel="stylesheet" type="text/css">
<script src="__JS_PATH__/jquery-1.8.3.js" type="text/javascript"></script>
<script src="__PUBLIC_PATH__/fancybox/source/jquery.fancybox.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
        $('.fancybox').fancybox();
	});
	
	function fancyboxClose(){	
		$.fancybox.close(); 
	}
</script>
</head>
<body>
<script language="javascript">
window.onload=function showtable(){
var tablename=document.getElementById("mytable");
var li=tablename.getElementsByTagName("tr");
var i=0;
for (i=0;i<=li.length-1;i++){
	li[i].style.backgroundColor="#fff";
	li[i].onmouseover=function(){
	this.style.backgroundColor="#f8f4f1";
}
	li[i].onmouseout=function(){
	this.style.backgroundColor="#fff"
}
}
}

/**
* 全选checkbox,注意：标识checkbox id固定为为check_box
* @author Tony
* @param string name 列表check名称,如 uid[]
*/
function selectall(name) {
	if ($("#check_box").attr("checked")=='checked') {
		$("input[name='"+name+"']").attr("checked","checked");
		$('.checkall').attr("checked"=='checked');
	} else {
		$("input[name='"+name+"']").removeAttr("checked");
		$('.checkall').removeAttr("checked");
	}
}
function confirm_delete(){
	if(confirm('确认删除吗？')) $('#myform').submit();
}
function confirmurl(url,str){
	if(confirm(str)){
	 location.href=url;
	}
}
//列表中修改单一数据的各种状态 added by Tony
function fetch_ajax(par,id){
	var imgUrl = '/Public/Admin/images/';
	var statusVal = $('#'+par+id).attr ('status');
	var value = $('#'+par+id).attr ('value');
	if(statusVal == 1){
	var imgName = 'no.gif';
	var status = 0;
	}else{
	var imgName = 'yes.gif';
	var status = 1;
	}
	if(statusVal!=1){
		if(confirm('你确定要改变桌位的状态吗？')){
			$.post('/index.php?g=Admin&m=Table&a=modifStatus',{'id':id,'value':value},function(re){
				if(re == 1){
					$('.tabStatus'+id).attr('status',0).attr('src',imgUrl+'no.gif');
					$('#'+par+id).attr ('status',status);
					$('#'+par+id).attr ('src',imgUrl+imgName);
				}
			});
		}
	}
} 
</script>

<style>
.added , .delete{background: none repeat scroll 0 0 #F0F0F0;
    border: 1px solid #E5E5E5;
    color: #444444;
    height: 23px;
    line-height: 23px;
    text-align: center;
    top: 0;
    width: 17px;}
.item-amount a:hover{ border-color:#FF0000; color:#FF0000;text-decoration:none;}
</style>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="mart15">
  <tr>
    <td width="4"><img src="__IMG_ADMIN_PATH__/gk1.png" width="4" height="39" /></td>
    <td background="__IMG_ADMIN_PATH__/gk2.png"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td width="23" class="xtgk2"><img src="__IMG_ADMIN_PATH__/gk_1.png" width="16" height="16" /></td>
          <td class="xtgk1"><?php echo ($tabNum); ?>号桌位详情</td>
        </tr>
      </table></td>
    <td width="5"><img src="__IMG_ADMIN_PATH__/gk3.png" width="5" height="39" /></td>
  </tr>
</table>
<table width="96%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#dca581">
  <tr>
    <td bgcolor="#FFFFFF"><table width="95%" id="mytable" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#efddd2" class="mart15 marb15 color333">
        <tr>
          <td align="center" bgcolor="#f5ede6"><h1>序号</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>菜名</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>缩略图</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>价格</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>数量</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>状态</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>操作</h1></td>
          <td align="center" bgcolor="#f5ede6"><h1>总计</h1></td>
        </tr>
        <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><tr>
            <td align="center"><?php echo ($key+1); ?></td>
            <td align="center"><?php echo ($v["name"]); ?></td>
            <td align="center"><img src="<?php echo ($v["pic"]); ?>" width="100"  height="100"/></td>
            <td align="center"><font class="price"><?php echo ($v["price"]); ?></font>元</td>
            <td align="center"><div class="item-amount amountUpdate" style="display:none"><a class="delete" href="#">-</a>
                <input class="amountVal" type="text" disabled="disabled" autocomplete="off" data-now="2" style="background-color: #FFFFFF; background-position: -75px -375px; border: 1px solid #AAAAAA; color: #343434; height: 15px; left: 18px; line-height: 15px; padding: 4px 0; text-align: center; top: 0; width: 30px;" data-max="2"  value="<?php echo ($v["amount"]); ?>">
                <a class="added" href="#">+</a></div><font class="amountOriginal" style=" margin-right:20px;"><?php echo ($v["amount"]); ?></font><font>[<a href="javascript:void(0);" dataid="<?php echo ($v["id"]); ?>" typeid="1" onclick="amount(this);">修改</a>]</font>
				</td>
            <td align="center">&nbsp;&nbsp;&nbsp;&nbsp;<?php if($v['check'] == 2): ?><font color="#008000">已下单</font>&nbsp;&nbsp;&nbsp;&nbsp;<?php elseif($v['check'] == 1): ?><font color="#008000">请求下单</font>&nbsp;&nbsp;&nbsp;&nbsp;<?php else: ?><font color="red">待下单</font>&nbsp;&nbsp;&nbsp;&nbsp;<?php endif; ?></font><?php if($v['status'] == 1): ?>&nbsp;&nbsp;&nbsp;&nbsp;<font color="red">[追加]</font><?php endif; ?></td>
            <td align="center"><a href="javascript:confirmurl('/index.php?g=admin&m=Index&a=delTempTab&id=<?php echo ($v["id"]); ?>','你确定要删除吗？');">删除</a></td>
            <td align="center"><font class="partPrice"><?php echo ($v["allPrice"]); ?></font>元</td>
          </tr><?php endforeach; endif; else: echo "" ;endif; ?>
        <tr>
          <td colspan="6" align="right" ><a href="/index.php?g=Admin&m=Index&a=printer&t_id=<?php echo ($v["t_id"]); ?>#btn"  class="fancybox fancybox.iframe" >打印预览</a><font style="margin-left:50px;">小计：</font></td>
          <td align="center" class="colorf00 fontweight"><font id="allPrice"><?php echo ($allPrice); ?></font>元</td>
        </tr>
      </table>
      <div style=" color: #FF6500; font-size: 14px; margin: 3px 3px 15px; padding: 3px; text-align: center;"> <?php echo ($page); ?> </div><?php if($settleInfo): ?><div style=" color: #FF6500; font-size: 22px; padding: 3px; text-align:left; margin-left:10%;"><?php echo (time_ago($settleInfo["createtime"])); ?>&nbsp; <?php if(($settleInfo['type']) == "1"): ?>(请求下单)<?php endif; if(($settleInfo['type']) == "2"): ?>(请求结账)<?php endif; ?></div><?php endif; ?><div style=" color: #FF6500; font-size: 14px; margin: 3px 30% 15px; padding: 3px; text-align:right;"><input style="margin-right:50px;" type="button" class="input10" value="确认下单"  onclick="confirmurl('/index.php?g=Admin&m=Index&a=order&t_id=<?php echo ($v["t_id"]); ?>','您确定下单吗？');" /><input type="button" class="input10" value="确认结账"  onclick="confirmurl('/index.php?g=Admin&m=Index&a=settle&t_id=<?php echo ($v["t_id"]); ?>','您确定结账吗？');" /></div></td>
  </tr>
</table>
</td>
</tr>
</table>
<script>
	//减少按钮绑定事件	  added by Tony
	$('.delete').click(function(){
		var amountVal = parseInt($(this).siblings('.amountVal').val());
		if(amountVal > 1){
			var amount = amountVal-1*1;
			$(this).siblings('.amountVal').val(amount);
		}
	});
	//增加按钮绑定事件	  added by Tony
	$('.added').click(function(){
		var amountVal = parseInt($(this).siblings('.amountVal').val());
		var amount = amountVal+1*1;
		$(this).siblings('.amountVal').val(amount);
	});
	//使用中餐桌某商品数量更改  added by Tony
	function amount(that){
		var type = $(that).attr('typeid');
		var id = $(that).attr('dataid');
		var amountOriginal = parseInt($(that).parent().siblings('.amountOriginal').html());
		if(type == 1){
			$(that).parent().siblings('.amountUpdate').show();
			$(that).parent().siblings('.amountOriginal').hide();
			$(that).attr('typeid',2).html('确定');
		}else if(type == 2){
			var amountVal = parseInt($(that).parent().siblings().find('.amountVal').val());
			if(amountOriginal != amountVal){
				if(confirm('你确定要修改吗？')){
					var price = parseInt($(that).parent().parent().siblings().find('.price').html());
					var oldPartPrice = parseInt($(that).parent().parent().siblings().find('.partPrice').html());
					var allPrice = parseInt($('#allPrice').html());
					var parPrice = (price*amountVal).toFixed(2);
					var nowAllPrice = (allPrice+(parPrice-oldPartPrice)).toFixed(2);
					$.post("/index.php?g=Admin&m=Index&a=updateTempTab",{'id':id,'amount':amountVal},function(re){
						if(re.status == 1){
							$(that).parent().siblings('.amountOriginal').html(amountVal);
							$(that).parent().parent().siblings().find('.partPrice').html(parPrice)
							$('#allPrice').html(nowAllPrice);
						}else{
							alert('修改失败！');
						}
					},'json');
				}else{
					$(that).parent().siblings().find('.amountVal').val(amountOriginal);
				}
			}
			$(that).parent().siblings('.amountUpdate').hide();
			$(that).parent().siblings('.amountOriginal').show();
			$(that).attr('typeid',1).html('修改');
		}
	}
</script>
<STYLE type=text/css media=screen>
ul{ padding:0px; margin:0px;}
#downmsg_emessage {Z-INDEX: 100; RIGHT: 0px; BACKGROUND: url(__IMG_ADMIN_PATH__/down_msg_bg.gif) no-repeat left top; WIDTH: 225px; BOTTOM: 0px; POSITION: fixed; _position: absolute}
#donwmsg_head {MARGIN-TOP: 1px; DISPLAY: inline; FONT-SIZE: 12px; FLOAT: left; MARGIN-LEFT: 26px; COLOR: #ffffff}
#downmsgBar .close {MARGIN-TOP: 6px; DISPLAY: block; FLOAT: right; WIDTH: 11px; MARGIN-RIGHT: 5px; HEIGHT: 11px}
#downmsgBar {HEIGHT: 25px}
#donwmsg_content {OVERFLOW: hidden; HEIGHT: 162px}
#donwmsg_content UL {PADDING-RIGHT: 10px; height:68%; PADDING-LEFT: 10px; FONT-SIZE: 12px; LEFT: 6px; PADDING-BOTTOM: 0px; COLOR: #007cc1; LINE-HEIGHT: 180%; PADDING-TOP: 10px; TOP: 34px}
#donwmsg_content UL LI {BACKGROUND: url(__IMG_ADMIN_PATH__/down_msg_bg.gif) no-repeat -100px -245px; TEXT-INDENT: 13px}
#donwmsg_content UL LI A {COLOR: #007cc1}
#donwmsg_content UL .ll A {	FONT-WEIGHT: bold; COLOR: #a10000}
#donwmsg_content P {LEFT: 13px; POSITION: absolute; TOP: 157px}
#donwmsg_content .lb {PADDING-RIGHT: 14px; PADDING-LEFT: 14px; PADDING-BOTTOM: 14px; PADDING-TOP: 14px; TEXT-ALIGN: center}
#donwmsg_content .lb a{ font-size:13px;}
.msg-hidden-btn-2 {MARGIN-TOP: 6px; DISPLAY: block; BACKGROUND: url(__IMG_ADMIN_PATH__/down_msg_bg.gif) no-repeat left -250px; FLOAT: right; OVERFLOW: hidden; WIDTH: 11px; MARGIN-RIGHT: 5px; HEIGHT: 11px}
.msg-hidden-btn-1 {MARGIN-TOP: 6px; DISPLAY: block; BACKGROUND: url(__IMG_ADMIN_PATH__/down_msg_bg.gif) no-repeat -50px -250px; FLOAT: right; OVERFLOW: hidden; WIDTH: 11px; MARGIN-RIGHT: 5px; HEIGHT: 11px}
.sectionshover .trans {	BORDER-RIGHT: #ffc600 1px solid; BORDER-TOP: #ffc600 1px solid; BORDER-LEFT: #ffc600 1px solid; BORDER-BOTTOM: #ffc600 1px solid; HEIGHT: 24px; BACKGROUND-COLOR: #fff0b6
}
.sectionshover .trans LI {CLEAR: none; FLOAT: left; WIDTH: 200px}
.mm_gg LI {PADDING-LEFT: 15px; BACKGROUND: url(__IMG_ADMIN_PATH__/1254189745035.gif) no-repeat 4px 8px; LINE-HEIGHT: 20px}
.mm_gg LI A {COLOR: #8f3434}
.mm_gg LI A:hover {	COLOR: #8f3434}
.mm_gg LI:visited {COLOR: #8f3434}
</STYLE>
<script src="__JS_ADMIN_PATH__/jsc.js" type="text/javascript"></script>
<script src="__JS_ADMIN_PATH__/lightbox.js" type="text/javascript"></script>
<DIV id=downmsg_emessage style="DISPLAY: none ">
    <DIV id=downmsgBar>
        <DIV id=donwmsg_head>系统提示</DIV>
        <A class=close href="javascript:closeDiv()"></A>
        <A class=msg-hidden-btn-1 id=msg_hidden_btn href="javascript:showHideDiv()">&nbsp;</A>
    </DIV>
    <DIV id=donwmsg_content>
          <UL id="settleShow">
          </UL>
          <DIV class=lb>请赶往处理!</DIV>
    </DIV>
</DIV>
<script src="__JS_ADMIN_PATH__/down_msg.js" type="text/javascript"></script>
<SCRIPT type=text/javascript>
var downmsg = new downMsg("downmsg_emessage","donwmsg_content",{start_delay:2000, speed: 5, movepx:2,cookie:'downMsgcookie',expiresDay:1});
	window.setInterval(getSettle, 30000);//每隔30秒获取一次
//自动获取请求表数据	added by Tony
function getSettle(){
	$.post('/index.php?g=Admin&m=Login&a=getSettle','',function(html){
		var htmlLength = html.length;
		if(htmlLength){
			$('#settleShow').html(html);
			var msg_hidden_btn = $('#msg_hidden_btn').hasClass('msg-hidden-btn-1');
			if(msg_hidden_btn){
				downmsg.start();
				setTimeout('closeDiv()',10000);
			}
		}
	});
}
</SCRIPT>
</body></html>